package jjn.round2;

/**
 * @author Jiang Jining
 * @since 2023-05-07 0:55
 */
public class LeetCode1010_numPairsDivisibleBy60 {
    public int numPairsDivisibleBy60(int[] time) {
        int[] pairs = new int[60];
        long total = 0;
        for (int t : time) {
            int tf = t % 60;
            pairs[tf] = pairs[tf] + 1;
        }
        for (int i = 1; i < 30; i++) {
            total += (long) pairs[i] * pairs[60 - i];
        }
        total += (long) pairs[0] * (pairs[0] - 1) / 2 + (long) pairs[30] * (pairs[30] - 1) / 2;
        return (int) total;
    }
}
